/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package conexion;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author Administrador
 */
class CommunicationThread extends Thread{
    private SocketListener listener;
    private BufferedReader in;   
    public CommunicationThread(BufferedReader in,SocketListener listener){
        this.listener = listener;
        this.in = in;       
    }
    @Override
    public void run(){
        while(true){
          try{
            String line = in.readLine();
            if(!line.equals("")){
                //System.out.println(line);
                listener.receiveData(line);
            }
          } catch (IOException e) {
            System.out.println("Read failed");
            System.exit(-1);
          }
      }
    }
}